package com.medical.manage.controller;

import com.medical.common.core.domain.Result;
import com.medical.common.core.web.controller.BaseController;
import com.medical.common.log.annotation.Log;
import com.medical.common.log.enums.BusinessType;
import com.medical.common.security.annotation.RequiresPermissions;
import com.medical.manage.domain.Department;
import com.medical.manage.domain.Diseases;
import com.medical.manage.domain.Medicine;
import com.medical.manage.mapper.DiseasesMapper;
import com.medical.manage.service.DiseasesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

/**
 * @Author：waikaipeng
 * @Package：com.medical.manage.controller
 * @Project：medical
 * @name：PharmacologyController
 * @Date：2025年3月6日 19:36
 */
@RestController
@RequestMapping("/diseases")
public class DiseasesController extends BaseController {

    @Autowired
    private DiseasesService diseasesService;

    //疾病详情
    @RequiresPermissions("manage:diseases:list")
    @GetMapping("/list")
    public Result list(Diseases diseases){
        startPage();
        List<Diseases> list = diseasesService.list();
        return getDataTable(list);
    }



    //详情页添加
    @RequiresPermissions("manage:diseases:add")
    @Log(title = "疾病详情", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody Diseases diseases){
        diseasesService.save(diseases);
        return success();
    }



    //详情页修改
    @RequiresPermissions("manage:diseases:edit")
    @Log(title = "疾病详情", businessType = BusinessType.INSERT)
    @PutMapping
    public Result edit(@RequestBody Diseases diseases){
        diseasesService.updateById(diseases);
        return success();
    }




    //详情页删除
    @RequiresPermissions("manage:diseases:remove")
    @Log(title = "疾病详情", businessType = BusinessType.INSERT)
    @DeleteMapping("/{disIds}")
    public Result remove(@PathVariable Long[] disIds){
        List<Long> list = Arrays.asList(disIds);
        diseasesService.removeBatchByIds(list);
        return success();

    }
}
